import { useState } from "react";
import { Button } from "antd";
import CardDrawer from "./card-drawer";

type EditButtonProps = {
  userId: number;
  children: React.ReactNode;
};

export default function EditButton({ userId, children }: EditButtonProps) {
  const [open, setOpen] = useState(false);

  const handleOpen = () => setOpen(true);
  const handleClose = () => setOpen(false);

  return (
    <>
      <Button type="link" size="small" onClick={handleOpen}>
        {children}
      </Button>
      <CardDrawer open={open} userId={userId} onClose={handleClose} />
    </>
  );
}
